package com.imay.live.activity.discovery;

import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.widget.FrameLayout;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.imay.live.activity.BaseRequestActivity;
import com.imay.live.view.custom.LoadRefreshViewControl;
import com.imay.live.view.recyclerview.WrapContentLinearLayoutManager;
import com.imay.live.R;
import com.lcodecore.tkrefreshlayout.RefreshListenerAdapter;
import com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout;

import java.util.ArrayList;

/**
 * Created by liangzhenxiong on 2017/04/11 0011.
 */

public class DicLoadActivity extends BaseRequestActivity {
    public RecyclerView mrecyclerView;
    protected ArrayList<Object> mdatas;
    protected LoadRefreshViewControl loadViewControl;
    protected int mpapecount = 20;
    protected FrameLayout container;
    protected BaseQuickAdapter<Object, BaseViewHolder> mAdapter;


    @Override
    protected int getLayoutId() {
        return R.layout.recycler_content;
    }

    public void onRefreshLoad() {
    }

    public void onLoadMore() {
    }

    protected void initAdapte() {
        mdatas = new ArrayList<Object>();
    }

    protected void initCreate(Bundle savedInstanceState) {

    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        container = $(R.id.container);
        initAdapte();
        loadViewControl = new LoadRefreshViewControl(DicLoadActivity.this, mAdapter, mpapecount);
        mrecyclerView = loadViewControl.addLoadView(container, new RefreshListenerAdapter() {
            @Override
            public void onRefresh(TwinklingRefreshLayout refreshLayout) {
                onRefreshLoad();
            }

            @Override
            public void onLoadMore(TwinklingRefreshLayout refreshLayout) {
                DicLoadActivity.this.onLoadMore();
            }
        });
        mAdapter.bindToRecyclerView(mrecyclerView);
        WrapContentLinearLayoutManager wrapContentLinearLayoutManager
                = new WrapContentLinearLayoutManager(this);
        mrecyclerView.setLayoutManager(wrapContentLinearLayoutManager);
        mrecyclerView.setHasFixedSize(true);
        initCreate(savedInstanceState);

    }
}
